package name.jiaosha.air.iostorage.controller;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import name.jiaosha.air.AppConstants;
import name.jiaosha.air.iostorage.domain.SaleItem;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/admin")
public class OutputStorageController {

	@RequestMapping("/saleItem/getSaleItems")
	public ModelAndView getSaleItems(){
		
		List<SaleItem> list = null;
		int total=0;

		if (AppConstants.DEBUG) {
			list = new ArrayList<SaleItem>();			
			for (int i = 0; i < 10; i++) {
				SaleItem saleItem = new SaleItem();
				saleItem.setId(i);
				saleItem.setDocID("20100910001");
				saleItem.setName("底盘部件W240L.1"+i);
				saleItem.setProductCode("201245240359"+i);
				saleItem.setAmount(new BigDecimal(10+i));
				saleItem.setUnit("个");
				saleItem.setUnitPrice(new BigDecimal(50+i));
				saleItem.setStorageId(i);
				list.add(saleItem);
			}
			total=list.size();

		} else {

		}

		ModelMap model = new ModelMap();
		model.addAttribute("root", list);
		model.addAttribute("totalProperty", total);
		return new ModelAndView("jsonView", model);
	}
}
